import request from '@/utils/request'

/**
 * 查询数据字典信息
 * @param {*} dictType
 */
export function fetchDictMap(dictType) {
  const data = dictType instanceof Array ? dictType : [dictType]
  const params = new URLSearchParams()
  params.append('dictType', data)
  return request({
    url: '/base/common/dict',
    method: 'get',
    params: params
  })
}

/**
 * 查询币种数据信息
 */
export function fetchCurrencyArray() {
  return request({
    url: '/base/common/currency',
    method: 'get'
  })
}

/**
 * 查询国别地区数据信息
 */
export function fetchCountryArray() {
  return request({
    url: '/base/common/country',
    method: 'get'
  })
}

/**
 * 获取下级经济行业列表
 */
export function fetchSubIndustryList(industryCode) {
  return request({
    url: '/base/common/industry',
    method: 'get',
    params: { industryCode }
  })
}

/**
 * 查询上级经济类型信息数组
 * @param {*} industryCode
 */
export function getParentIndustryArray(industryCode) {
  return request({
    url: '/base/common/industry/parent',
    method: 'get',
    params: { industryCode }
  })
}

/**
 * 获取下级行政区划信息列表
 */
export function fetchSubAreaList(areaCode) {
  return request({
    url: '/base/common/area',
    method: 'get',
    params: { areaCode }
  })
}

/**
 * 查询上级区域信息数组
 * @param {*} areaCode
 */
export function getParentAreaArray(areaCode) {
  return request({
    url: '/base/common/area/parent',
    method: 'get',
    params: { areaCode }
  })
}

/**
 * 获取短信验证码
 */
export function getSmsCaptcha(params) {
  return request({
    url: '/user/getSmsCaptcha',
    method: 'post',
    data: params
  })
}

/**
 * 获取验证码
 */
export function getCaptchaw150h40() {
  return request({
    url: '/anon/captchaw150h40',
    method: 'get'
  })
}

/**
 * 获取用户授权访问机构树信息
 */
export function getAuthOrgTree() {
  return request({
    url: '/base/common/org/tree',
    method: 'get'
  })
}

export function fetchOrgArray(params) {
  return request({
    url: '/base/common/org/select',
    method: 'get',
    params: params
  })
}

export function getOrgInfo(orgCode) {
  return request({
    url: '/base/common/orginfo',
    method: 'get',
    params: { orgCode }
  })
}

export function fetchUserArray(query, orgCode) {
  return request({
    url: '/base/common/user/select',
    method: 'get',
    params: { query, orgCode }
  })
}
